<?php
/**
 * 公众号页面授权接口
 * @author lss
 * 2017-03-02
 */
namespace soa\mp;

use soa\client;

class JS  extends client
{
    /**
     * 服务地址
     * @var string
     */
    public $service_url = 'http://mp.kuaidihelp.com/';

    /**
     * 服务名称
     * @var string
     */
    protected $service_name = 'kuaidihelp_mp';

	/**
	 * 前端调用微信jsApi的凭证
	 * @param $url
	 * @param $platform
	 * @return array
	 */
	public function jsPackage($url,$platform = "weixin"){
		if(!stristr($platform,"_")){
			return $this->post("api/JS/sign",[
					"url" => $url,
					"company" => "kb",
					"platform" => $platform,
				]
			);
		}else{
			return $this->post("api/JS/open",[
					"url" => $url,
					"state" => $platform,
				]
			);
		}
	}

	/**
	 * 获取调用微信卡券相关的jsApi的凭证
	 * @param $url
	 * @param string $platform
	 * @return array
	 */
	public function card($platform = "weixin",$cardId = "",$cardType = "",$poiId = ""){
		return $this->post("api/JS/card",[
				"cardId" => $cardId,
				"cardType" => $cardType,
				"poiId" => $poiId,
				"platform" => $platform,
			]
		);
	}
}